package com.github.shiqiyue.learn.guava;

import com.google.common.primitives.Floats;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.List;

/***
 * 描述
 * @author wenyao.wu
 * @date 2018/7/3
 */
public class FloatsTest {

    private static final Logger logger = LoggerFactory.getLogger(FloatsTest.class);

    public static void main(String[] args) {
        float[] floatArray = {1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f, 7.0f, 8.0f, 9.0f};

        //convert array of primitives to array of objects
        List<Float> objectArray = Floats.asList(floatArray);

        logger.info("{}", objectArray);
        //check if element is present in the list of primitives or not
        logger.info("5.0 is in list? {}", Floats.contains(floatArray, 5.0f));

        //return the index of element
        logger.info("5.0 position in list {}", Floats.indexOf(floatArray, 5.0f));

        //Returns the minimum
        logger.info("Min: {}", Floats.min(floatArray));

        //Returns the maximum
        logger.info("Max: {}", Floats.max(floatArray));
    }
}
